package reactor;

import java.io.IOException;
import java.nio.channels.SocketChannel;
/**
 * @Author: linKe
 * @Date: 2022/1/15 15:05
 * @FileName: Acceptor
 * @version: 1.0
 * @Description: 受体
 */
public class Acceptor implements Runnable {
    /**
     *  reactor
     */
    private Reactor reactor;

    public Acceptor(Reactor reactor) {
        this.reactor = reactor;
    }

    @Override
    public void run() {
        try {
            SocketChannel channel = reactor.serverSocketChannel.accept();
            if (channel != null) {
                new SocketReadHandler(reactor.selector, channel);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

}
